//
//  WBVisitorTableViewController.swift
//  0829-Weibo
//
//  Created by 毕仲阳 on 16/8/30.
//  Copyright © 2016年 mycompany. All rights reserved.
//

import UIKit

class WBVisitorTableViewController: UITableViewController {

    var userInfo = WBUserAccountViewModel.sharedModel.userLogin
    override func loadView() {
        if userInfo
        {
            super.loadView()
        }else
        {
            setVisitorView()
        }
    }
    
    func setVisitorView()
    {
        let v = visitorView
        self.view = v
    }
    lazy var visitorView:WBVisitorView =
    {
            let v = WBVisitorView()
            return v
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        //判断登录之后就不再显示登录和注册的按钮
        if WBUserAccountViewModel.sharedModel.userLogin == false
        {
        navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: nil, title: "注册", target: nil, action: nil)
        navigationItem.rightBarButtonItem = UIBarButtonItem(imageName: nil, title: "登录", target: self, action: #selector(visitorViewWillLogin))
        }
        visitorView.loginButton.addTarget(self, action: #selector(visitorViewWillLogin), for: UIControlEvents.touchUpInside)
    }
    

   func visitorViewWillLogin()
   {
    let vc = WBNavigationController(rootViewController:WBOAuthController())
    present(vc, animated: true, completion: nil)
    }
}
